<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a lay-href="">主页</a>
        <a><cite>系统管理</cite></a>
        <a><cite>系统设置</cite></a>
    </div>
</div>
<style>
    .layui-form-label {
        width:20% !important;
        margin-left:1%;
    }
    .layui-input-inline {
        width: 40% !important;
    }
    .layui-clean-table .layui-form-checkbox span {
        width: 100px;
    }
</style>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-tab layui-tab-brief" lay-filter="xxpay_tab_sysConfig">
            <ul class="layui-tab-title">
                <li class="layui-this">网站设置</li>
                <li class="">上传附件设置</li>
                <li class="">短信配置</li>
                <li>结算设置</li>
                <li>安全设置</li>
                <li>代付设置</li>
                <li>接口文档</li>
                <li>系统参数配置</li>
                <li>数据清理</li>
                <li>订单提醒设置</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-form layui-form-pane layui-tab-item layui-show" >
                        <input type="hidden" name="type" value="site" >
                        <div class="layui-form-item">
                            <label class="layui-form-label">网站标题</label>
                            <div class="layui-input-inline">
                                <input type="text" name="siteTitle" id="siteTitle" placeholder="网站标题"  autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">版权信息</label>
                            <div class="layui-input-inline">
                                <input type="text" name="copyRight" id="copyRight" placeholder="版权信息"  autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">联系方式1</label>
                            <div class="layui-input-inline">
                                <input type="text" name="serviceTel" id="serviceTel" placeholder="联系方式1"  autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">联系方式2</label>
                            <div class="layui-input-inline">
                                <input type="text" name="serviceQQ" id="serviceQQ" placeholder="联系方式2"  autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label"><span class="requiredSpan"> </span>网站icon</label>
                            <div class="layui-input-inline">
                                <input class="imgVal" type="hidden" name="siteIcon" id="siteIcon" />
                                <img class="uploadImg layui-hide" style="height:38px; margin-left:30px;cursor: pointer;" title="点击放大" />
                                <button class="uploadImgBtn layui-btn layui-btn-sm" type="button" style="margin-left: 20px;">上传图片</button>
                                <button class="delImgBtn layui-btn layui-btn-sm layui-btn-danger layui-hide" type="button">删除图片</button>
                                <span style="color: #1E9FFF"> （建议尺寸：32X32）</span>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label"><span class="requiredSpan"> </span>网站Logo</label>
                            <div class="layui-input-inline">
                                <input class="imgVal" type="hidden" name="siteLogo" id="siteLogo" />
                                <img class="uploadImg layui-hide" style="height:38px; margin-left:30px;cursor: pointer;" title="点击放大" />
                                <button class="uploadImgBtn layui-btn layui-btn-sm" type="button" style="margin-left: 20px;">上传图片</button>
                                <button class="delImgBtn layui-btn layui-btn-sm layui-btn-danger layui-hide" type="button">删除图片</button>
                                <span style="color: #1E9FFF"> （建议尺寸：124X30）</span>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label"><span class="requiredSpan"> </span>商户首页banner</label>
                            <div class="layui-input-inline">
                                <input class="imgVal" type="hidden" name="mchHomeBanner" id="mchHomeBanner" />
                                <img class="uploadImg layui-hide" style="height:38px; margin-left:30px;cursor: pointer;" title="点击放大" />
                                <button class="uploadImgBtn layui-btn layui-btn-sm" type="button" style="margin-left: 20px;">上传图片</button>
                                <button class="delImgBtn layui-btn layui-btn-sm layui-btn-danger layui-hide" type="button">删除图片</button>
                                <span style="color: #1E9FFF"> （建议尺寸：1920X600）</span>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">统计代码</label>
                            <div class="layui-input-inline">
                                <input type="text" name="statisticalCode" id="statisticalCode" placeholder="统计代码"  autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">首页主广告语1</label>
                            <div class="layui-input-inline">
                                <input type="text" name="mainAdvert" id="mainAdvert" placeholder="商户首页主广告语1"  autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">首页主广告语2</label>
                            <div class="layui-input-inline">
                                <input type="text" name="mainAdvertEn" id="mainAdvertEn" placeholder="首页主广告语2"  autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">首页副广告语</label>
                            <div class="layui-input-inline">
                                <input type="text" name="subAdvert" id="subAdvert" placeholder="商户首页副广告语"  autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="system_config">确认保存</button>
                            </div>
                        </div>
                </div>
                <div class="layui-form layui-form-pane layui-tab-item" >
                    <input type="hidden" name="type" value="uploadFile" >
                    <div class="layui-form-item">
                        <label class="layui-form-label">存储位置</label>
                        <div class="layui-input-inline">
                            <input name="uploadFileSaveType" lay-filter="uploadFileSaveTypeFilter" value='1' type="radio" title="本地服务器" checked />
                            <input name="uploadFileSaveType" lay-filter="uploadFileSaveTypeFilter" value='2' type="radio" title="阿里云OSS存储" />
                        </div>
                    </div>
                    <div class="aliyunOssDiv layui-hide">
                        <div class="layui-form-item">
                            <label class="layui-form-label">EndPoint地域节点</label>
                            <div class="layui-input-inline">
                                <input class="layui-input" id="ossEndpoint" name="ossEndpoint" placeholder="请输入阿里云EndPoint地域节点（不包含http://和https://）"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">bucketName</label>
                            <div class="layui-input-inline">
                                <input class="layui-input" id="ossBucketName" name="ossBucketName" placeholder="请输入您创建的阿里云bucketName"/>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">accessKeyId</label>
                            <div class="layui-input-inline">
                                <input class="layui-input" id="ossAccessKeyId" name="ossAccessKeyId" placeholder="请输入您的阿里云accessKeyId"/>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">accessKeySecret</label>
                            <div class="layui-input-inline">
                                <input class="layui-input" id="ossAccessKeySecret" name="ossAccessKeySecret" placeholder="请输入您的阿里云accessKeySecret"/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <button type="button" class="layui-btn" lay-submit="" lay-filter="updateUploadConfigFilter" style="margin-left: 60px;">确认保存</button>
                        </div>
                    </div>
                </div>

                <div class="layui-form layui-form-pane layui-tab-item" >
                    <input hidden name="type" value="smsConfig">
                    <div class="layui-form-item">
                        <label class="layui-form-label">accessKeyId</label>
                        <div class="layui-input-inline">
                            <input type="text" id="smsAccessKeyId" name="accessKeyId" required autocomplete="off" class="layui-input" />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">accessKeySecret</label>
                        <div class="layui-input-inline">
                            <input type="text" id="smsAccessKeySecret" name="accessKeySecret" required autocomplete="off" class="layui-input" />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">短信签名(signName)</label>
                        <div class="layui-input-inline">
                            <input type="text" id="smsSignName" name="signName" required autocomplete="off" class="layui-input" />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">模板(templates)</label>
                        <div class="layui-input-inline" style="width: 700px!important;">
                            <table id="XxPay_SmsConfig_Poll_dataAll" lay-filter="XxPay_SmsConfig_Poll_dataAll"></table>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <button type="button" class="layui-btn" lay-submit="" lay-filter="updateSmsConfig" style="margin-left: 180px;">保存</button>
                        </div>
                    </div>
                </div>

                <div class="layui-form layui-form-pane layui-tab-item">
                        <input type="hidden" name="type" value="sett" >
                        <div class="layui-form-item">
                            <label class="layui-form-label">提现开关</label>
                            <div class="layui-input-inline">
                                <input type="radio" name="drawFlag" value="1" title="开启" checked>
                                <input type="radio" name="drawFlag" value="0" title="关闭">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">允许星期几提现</label>
                            <div class="layui-input-inline">
                                <input type="checkbox" name="allowDrawWeekDay" title="星期一" value="1" lay-skin="primary">
                                <input type="checkbox" name="allowDrawWeekDay" title="星期二" value="2" lay-skin="primary">
                                <input type="checkbox" name="allowDrawWeekDay" title="星期三" value="3" lay-skin="primary">
                                <input type="checkbox" name="allowDrawWeekDay" title="星期四" value="4" lay-skin="primary">
                                <input type="checkbox" name="allowDrawWeekDay" title="星期五" value="5" lay-skin="primary">
                                <input type="checkbox" name="allowDrawWeekDay" title="星期六" value="6" lay-skin="primary">
                                <input type="checkbox" name="allowDrawWeekDay" title="星期日" value="7" lay-skin="primary">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">每日提现开始时间</label>
                            <div class="layui-input-inline">
                                <input type="text" name="drawDayStartTime" id="drawDayStartTime" placeholder="输入提现开始时间,格式为:01:30:00"  autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">每日提现结束时间</label>
                            <div class="layui-input-inline">
                                <input type="text" name="drawDayEndTime" id="drawDayEndTime" placeholder="输入提现结束时间,格式为:21:00:00"  autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">每日提现次数</label>
                            <div class="layui-input-inline">
                                <input type="tel" id="dayDrawTimes" name="dayDrawTimes" lay-verify="number" placeholder="输入每日提现次数" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">每日提现最大金额(元)</label>
                            <div class="layui-input-inline">
                                <input type="tel" id="drawMaxDayAmount" name="drawMaxDayAmount" lay-verify="number" placeholder="输入每日提现最大金额" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">单笔最大提现金额(元)</label>
                            <div class="layui-input-inline">
                                <input type="tel" id="maxDrawAmount" name="maxDrawAmount" lay-verify="number" placeholder="输入最大提现金额" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">单笔最小提现金额(元)</label>
                            <div class="layui-input-inline">
                                <input type="tel" id="minDrawAmount" name="minDrawAmount" lay-verify="number" placeholder="输入最小提现金额" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">结算手续费类型</label>
                            <div class="layui-input-inline" >
                                <input type="radio" name="feeType" value="1" title="百分比收费" lay-filter="feeTypeFilter">
                                <input type="radio" name="feeType" value="2" title="固定收费" lay-filter="feeTypeFilter" checked="checked">
                                <input type="radio" name="feeType" value="3" title="百分比收费+固定收费" lay-filter="feeTypeFilter">
                            </div>
                        </div>
                        <div class="layui-form-item" id="feeRateId" style="display: none">
                            <label class="layui-form-label">结算手续费比例(%)</label>
                            <div class="layui-input-inline">
                                <input type="tel" id="feeRate" name="feeRate" placeholder="输入结算手续费比例" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item" id="feeLevelId" style="display: none">
                            <label class="layui-form-label">每笔手续费(元)</label>
                            <div class="layui-input-inline">
                                <input type="tel" id="feeLevel" name="feeLevel" placeholder="输入每笔手续费" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item" id="drawFeeLimitId">
                            <label class="layui-form-label">单笔手续费上限(元)</label>
                            <div class="layui-input-inline">
                                <input type="tel" id="drawFeeLimit" name="drawFeeLimit" lay-verify="number" placeholder="输入单笔手续费上限" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">结算类型</label>
                            <div class="layui-input-inline">
                                <input type="radio" name="settType" value="1" title="自动结算" disabled="disabled">
                                <input type="radio" name="settType" value="0" title="手动提现" checked="checked" disabled="disabled">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">结算方式</label>
                            <div class="layui-input-inline">
                                <input type="radio" name="settMode" value="1" title="D0到账" checked="checked">
                                <input type="radio" name="settMode" value="2" title="D1到账">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="sett_config">确认保存</button>
                            </div>
                        </div>
                </div>
                <div class="layui-form-pane layui-tab-item">
                    <div class="layui-tab layui-tab-brief">
                        <ul class="layui-tab-title">
                            <li class="layui-this">密码安全</li>
                            <li>登录安全</li>
                        </ul>
                        <div class="layui-tab-content" style="height: 100%">
                            <div class="layui-tab-item layui-show">
                                <div class="layui-form">
                                    <input type="hidden" name="type" value="safe" >
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">商户/代理商默认登录密码</label>
                                        <div class="layui-input-inline">
                                            <input type="password" name="mchDefaultPwd" placeholder="若修改请输入新密码,8-16位的字母和数字组合"  autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">商户/代理商默认支付密码</label>
                                        <div class="layui-input-inline">
                                            <input type="password" name="mchDefaultPayPwd" placeholder="若修改请输入新密码,8-16位的字母和数字组合"  autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">运营平台超级密码</label>
                                        <div class="layui-input-inline">
                                            <input type="password" name="mgrSuperPwd" placeholder="若修改请输入新密码,8-16位的字母和数字组合"  autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-input-block">
                                            <button class="layui-btn" lay-submit lay-filter="safe_config">确认保存</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-tab-item">
                                <div class="layui-form">
                                    <input type="hidden" name="type" value="loginSafeConfig" >
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">登录失败锁定IP次数</label>
                                        <div class="layui-input-inline">
                                            <input type="number" id="loginCountConfig" name="loginCountConfig" class="layui-input" placeholder="请输入登录次数上限">
                                            <span style="font-size: xx-small;color: #cc0000">设置 '0' 则不限制次数；次数不得超过100。</span>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">拉黑类型</label>
                                        <div class="layui-input-inline">
                                            <input type="radio" name="loginToBlackType" value="0" title="系统拉黑" checked="checked" lay-filter="loginToBlackTypeFilter">
                                            <input type="radio" name="loginToBlackType" value="1" title="宝塔拉黑" lay-filter="loginToBlackTypeFilter">
                                        </div>
                                    </div>
                                    <div class="layui-form-item loginToBlackType">
                                        <label class="layui-form-label">宝塔URL</label>
                                        <div class="layui-input-inline">
                                            <input type="text" id="btUrlConfig" name="btUrlConfig" class="layui-input" placeholder="请输入宝塔URL">
                                        </div>
                                    </div>
                                    <div class="layui-form-item loginToBlackType">
                                        <label class="layui-form-label">宝塔秘钥</label>
                                        <div class="layui-input-inline">
                                            <input type="text" id="btSignConfig" name="btSignConfig" class="layui-input" placeholder="请输入宝塔秘钥">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-input-block">
                                            <button class="layui-btn" lay-submit lay-filter="login_safe_config">确认保存</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-form layui-form-pane layui-tab-item">
                    <input name="type" value="agentpay" type="hidden" />
                    <div class="layui-form-item">
                        <label class="layui-form-label">商户代付出款账户</label>
                        <div class="layui-input-inline">
                            <input type="radio" name="agentpayOutAccount" value="1" title="收款账户">
                            <input type="radio" name="agentpayOutAccount" value="2" title="代付余额账户">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">代付打款方式</label>
                        <div class="layui-input-inline">
                            <input type="radio" name="agentpayAuditType" value="1" title="自动打款(仅限接口)">
                            <input type="radio" name="agentpayAuditType" value="2" title="人工审核">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">是否验证代付同卡同金额</label>
                        <div class="layui-input-inline">
                            <input name="agentpayCheckRepeatFlag" lay-filter="agentpayCheckRepeatFlagFilter" value='1' type="radio" title="是"/>
                            <input name="agentpayCheckRepeatFlag" lay-filter="agentpayCheckRepeatFlagFilter" value='0' type="radio" title="否" />
                        </div>
                    </div>
                    <div class="layui-form-item agentpayCheckRepeatTimeDiv">
                        <label class="layui-form-label">验证同卡同金额验证频率（单位：秒）</label>
                        <div class="layui-input-inline">
                            <input type="number" id="agentpayCheckRepeatTime" name="agentpayCheckRepeatTime" class="layui-input" placeholder="请输入验证频率">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">是否开启代付抢单模式</label>
                        <div class="layui-input-inline">
                            <input name="agentpaySnatchFlag" value='1' type="radio" title="是"/>
                            <input name="agentpaySnatchFlag" value='0' type="radio" title="否" />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">商户通道使用规则</label>
                        <div class="layui-input-inline">
                            <input type="radio" name="agentpayMchConfigFlag" value="1" title="使用默认通道" lay-filter="agentpayMchConfigFlagFilter">
                            <input type="radio" name="agentpayMchConfigFlag" value="2" title="按订单数量权重轮询" lay-filter="agentpayMchConfigFlagFilter">
                        </div>
                    </div>

                    <div class="layui-form-item layui-hide" id="agentpayMchConfig2QueryOrderTimeDIV">
                        <label class="layui-form-label">订单统计时间</label>
                        <div class="layui-input-inline">
                            <input type="text" id="agentpayMchConfig2QueryOrderTime" name="agentpayMchConfig2QueryOrderTime" class="layui-input" placeholder="订单统计时间， -1表示所有时间">
                            <p style="color: red"> 最近多久时间的总订单量，单位分，默认-1: 表示所有时间</p>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">代付审核允许的打款方式</label>
                        <div class="layui-input-inline" style="width: 60%!important;">
                            <input type="checkbox" name="agentpayChoosePayType" value="1" title="选择一种代付通道">
                            <input type="checkbox" name="agentpayChoosePayType" value="3" title="其他支付方式">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="agentpay_config">确认保存</button>
                        </div>
                    </div>
                </div>
                <div class="layui-form layui-form-pane layui-tab-item">
                    <input name="type" value="doc" type="hidden" />
                    <div class="layui-form-item">
                        <label class="layui-form-label">支付接口文档</label>
                        <div class="layui-input-inline">
                            <textarea name="payApiDoc" id="payApiDoc" placeholder="支付接口文档" class="layui-textarea"></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">代付接口文档</label>
                        <div class="layui-input-inline">
                            <textarea name="agentpayApiDoc" id="agentpayApiDoc" placeholder="支付接口文档" class="layui-textarea"></textarea>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="doc_config">确认保存</button>
                        </div>
                    </div>
                </div>

                <div class="layui-form layui-form-pane layui-tab-item" id="applicationConfigDiv">
                    <input name="type" value="applicationConfig" type="hidden" />

                    <div class="layui-form-item" style="margin-top:15px">
                        <label class="layui-form-label">运营系统地址（http开头，结尾不带/）</label>
                        <div class="layui-input-inline">
                            <input lay-verify="required" class="layui-input" name="mgrSiteUrl" placeholder="" />
                        </div>
                    </div>
                    <div class="layui-form-item" style="margin-top:15px">
                        <label class="layui-form-label">商户系统地址（http开头，结尾不带/）</label>
                        <div class="layui-input-inline">
                            <input lay-verify="required" class="layui-input" name="mchSiteUrl" placeholder="" />
                        </div>
                    </div>
                    <div class="layui-form-item" style="margin-top:15px">
                        <label class="layui-form-label">代理商系统地址（http开头，结尾不带/）</label>
                        <div class="layui-input-inline">
                            <input lay-verify="required" class="layui-input" name="agentSiteUrl" placeholder="" />
                        </div>
                    </div>
                    <div class="layui-form-item" style="margin-top:15px">
                        <label class="layui-form-label">支付网关地址（http开头，结尾不带/）</label>
                        <div class="layui-input-inline">
                            <input lay-verify="required" class="layui-input" name="paySiteUrl" placeholder="" />
                        </div>
                    </div>
                    <div class="layui-form-item" style="margin-top:15px">
                        <label class="layui-form-label">微信开放平台[获取code]请求接口</label>
                        <div class="layui-input-inline">
                            <input lay-verify="required" id="wxOauth2CodeUrl" class="layui-input" name="wxOauth2CodeUrl" placeholder="" />
                        </div>
                    </div>
                    <div class="layui-form-item" style="margin-top:15px">
                        <label class="layui-form-label">支付补单任务开关</label>
                        <div class="layui-input-inline">
                            <input type="checkbox" name="taskReissuePaySwitch" lay-filter="taskReissuePaySwitchFilter" lay-skin="switch" lay-text="开启|关闭">
                        </div>
                    </div>
                    <div class="layui-form-item layui-hide taskReissuePayIpDiv" style="margin-top:15px">
                        <label class="layui-form-label">支付补单任务IP</label>
                        <div class="layui-input-inline">
                            <input lay-verify="required" class="layui-input" name="taskReissuePayIp" placeholder="" />
                        </div>
                    </div>
                    <div class="layui-form-item" style="margin-top:15px">
                        <label class="layui-form-label">转账补单任务开关</label>
                        <div class="layui-input-inline">
                            <input type="checkbox" name="taskReissueTransSwitch" lay-filter="taskReissueTransSwitchFilter" lay-skin="switch" lay-text="开启|关闭">
                        </div>
                    </div>

                    <div class="layui-form-item layui-hide taskReissueTransIpDiv" style="margin-top:15px">
                        <label class="layui-form-label">转账补单任务IP</label>
                        <div class="layui-input-inline">
                            <input lay-verify="required" class="layui-input" name="taskReissueTransIp" placeholder="" />
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">清理数据开关</label>
                        <div class="layui-input-inline">
                            <input type="radio" name="cleanFlag" value="1" title="开启">
                            <input type="radio" name="cleanFlag" value="0" title="关闭" checked>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="application_config">确认保存</button>
                        </div>
                    </div>
                </div>
                <div class="layui-form layui-form-pane layui-tab-item">
                    <input type="hidden" name="type" value="clean" >
                    <div class="layui-form-item">
                        <label class="layui-form-label">选择时间范围</label>
                        <div class="layui-input-inline" style="width: 25% !important;">
                            <select id="dataSelect" name="dataSelect" lay-filter="dateSelectFilter">
                                <option value="1">全部时间</option>
                                <option value="2">自定义时间</option>
                            </select>
                        </div>
                        <div class="layui-input-inline"  style="display: none;width: 25% !important;" id="customTime">
                            <input type="text" name="cleanTime" id="cleanTime" placeholder="输入的清理时间之前的数据将被删除"  autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item layui-clean-table">
                        <label class="layui-form-label">选择清理的表</label>
                        <div class="layui-input-inline">
                            <input type="checkbox" name="chooseAll" id="all" title="全选" value="0" lay-skin="primary" lay-filter="chooseAll">
                            <input type="checkbox" name="cleanTableCheck" id="payOrder" title="支付订单" value="1" lay-skin="primary">
                            <input type="checkbox" name="cleanTableCheck" id="transOrder" title="转账订单" value="2" lay-skin="primary">
                            <input type="checkbox" name="cleanTableCheck" id="agentpayOrder" title="代付订单" value="3" lay-skin="primary">
                            <input type="checkbox" name="cleanTableCheck" id="settOrder" title="结算订单" value="4" lay-skin="primary">
                            <input type="checkbox" name="cleanTableCheck" id="mchAccountHistory" title="商户资金流水" value="5" lay-skin="primary">
                            <input type="checkbox" name="cleanTableCheck" id="agentAccountHistory" title="代理商资金流水" value="6" lay-skin="primary">
                            <input type="checkbox" name="cleanTableCheck" id="mchNotify" title="支付通知" value="8" lay-skin="primary">
                            <input type="checkbox" name="cleanTableCheck" id="payOrderLog" title="支付日志" value="13" lay-skin="primary">
                            <input type="checkbox" name="cleanTableCheck" id="mchBill" title="商户对账表" value="9" lay-skin="primary">
                            <input type="checkbox" name="cleanTableCheck" id="mgrSysLog" title="系统操作日志" value="10" lay-skin="primary">
                            <input type="checkbox" name="cleanTableCheck" id="statisticsPlat" title="平台统计表" value="14" lay-skin="primary">
                            <input type="checkbox" name="cleanTableCheck" id="statisticsMch" title="商户统计表" value="15" lay-skin="primary">
                            <input type="checkbox" name="cleanTableCheck" id="statisticsPayPassage" title="通道统计表" value="16" lay-skin="primary">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="clean_config">立即清理</button>
                        </div>
                    </div>
                </div>

                <div class="layui-form layui-form-pane layui-tab-item">



                    <input type="hidden" name="type" value="sysTips" >


                    <fieldset class="layui-elem-field">
                        <legend><button class='layui-btn layui-btn-xs layui-btn-normal'>运营平台系统</button></legend>

                        <div class="layui-form-item" style="margin-top:15px">
                            <label class="layui-form-label">[新支付订单] 提醒</label>
                            <div class="layui-input-inline">
                                <input type="checkbox" name="mgrPayOrderAllTipFlag" lay-filter="sysTipSwitch" lay-skin="switch" lay-text="开启|关闭" />
                                <span class="layui-hide sysTipsSoundSpan">
                                <input name="mgrPayOrderSoundFlag" type="checkbox" lay-skin="switch" lay-text="提示音开|提示音关" />
                            </span>
                            </div>
                        </div>

                        <div class="layui-form-item" style="margin-top:15px">
                            <label class="layui-form-label">[新代付订单] 提醒</label>
                            <div class="layui-input-inline">
                                <input type="checkbox" name="mgrAgentpayOrderAllTipFlag" lay-filter="sysTipSwitch" lay-skin="switch" lay-text="开启|关闭" />
                                <span class="layui-hide sysTipsSoundSpan">
                                <input name="mgrAgentpayOrderSoundFlag" type="checkbox" lay-skin="switch" lay-text="提示音开|提示音关" />
                            </span>
                            </div>
                        </div>

                        <div class="layui-form-item" style="margin-top:15px">
                            <label class="layui-form-label">[新结算订单] 提醒</label>
                            <div class="layui-input-inline">
                                <input type="checkbox" name="mgrSettOrderAllTipFlag" lay-filter="sysTipSwitch" lay-skin="switch" lay-text="开启|关闭" />
                                <span class="layui-hide sysTipsSoundSpan">
                                <input name="mgrSettOrderSoundFlag" type="checkbox" lay-skin="switch" lay-text="提示音开|提示音关" />
                            </span>
                            </div>
                        </div>

                    </fieldset>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="update_sys_tips_config">保存设置</button>
                        </div>
                    </div>
                </div>


            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['form', 'laydate', 'element', 'admin','code', 'upload', 'setter', 'table'],function(){
        var form = layui.form
            , $ = layui.$
            , element = layui.element
            , laydate = layui.laydate
            , layer = layui.layer
            , code = layui.code
            ,admin = layui.admin
            ,upload = layui.upload
            ,setter = layui.setter
            ,table = layui.table;

        element.render();

        //上传图片接口
        var headers = {};
        headers[setter.request.tokenName] = layui.data(setter.tableName)[setter.request.tokenName];
        upload.render({
            url: layui.setter.baseUrl + '/upload/putImg?'+setter.request.tokenName+"="+layui.data(setter.tableName)[setter.request.tokenName]
            , elem: '.uploadImgBtn'
            , headers: headers
            ,accept: 'file'
            , size: 2048  //仅支持2M图片上传
            ,done: function(res, index, upload){

                //如果上传失败
                if(res.code != 0){
                    return layer.msg('上传失败['+res.msg+']', {icon: 2});
                }
                var divElem = $(this.item).parent();
                divElem.find('.imgVal').val(res.data); //图片真实路径
                divElem.find('.uploadImg').attr("src", res.data).removeClass('layui-hide');
                divElem.find('.delImgBtn').removeClass('layui-hide');
                divElem.find('.uploadImgBtn').text('重新上传');
                form.render();
            }
        });

        //点击[删除图片] 按钮， 事件
        $('.delImgBtn').click(function(){

            var divElem = $(this).parent();
            divElem.find('.imgVal').val(""); //清空图片真实路径
            divElem.find('.uploadImgBtn').text("上传图片");
            divElem.find('.uploadImg').attr("src", "").addClass('layui-hide');
            divElem.find('.delImgBtn').addClass('layui-hide');
            form.render();
        });

        //点击[图片] 按钮， 事件
        $('body').on('click', '.uploadImg', function(){
            var imgSrc = $(this).attr('src');
            layer.photos({photos: {
                    "title": "查看上传图片", //相册标题
                    "id": 1, //相册id
                    "start": 0, //初始显示的图片序号，默认0
                    "data": [   //相册包含的图片，数组格式
                        {
                            "alt": "图片",
                            "pid": 1, //图片id
                            "src": imgSrc, //原图地址
                            "thumb": "" //缩略图地址
                        }
                    ]
                } ,anim: 5});
        });

        var setImgValFunc = function(inputName, src){
            var divElem = $("input[name='"+inputName+"']").parent();
            divElem.find('.imgVal').val(src); //图片真实路径
            divElem.find('.uploadImg').attr("src", src).removeClass('layui-hide');
            divElem.find('.delImgBtn').removeClass('layui-hide');
            divElem.find('.uploadImgBtn').text('重新上传');
        }


        admin.req({
            type: 'get',
            url: layui.setter.baseUrl + '/sys/config/getAll',
            error: function(err){
                layer.alert(JSON.stringify(err.field), {
                    title: '错误提示'
                })
            },
            success: function(res){
                if(res.code == 0){
                    $("input[name='drawFlag'][value='"+res.data.drawFlag+"']").attr("checked",true);
                    var allowDrawWeekDay = res.data.allowDrawWeekDay;
                    if(allowDrawWeekDay != null && allowDrawWeekDay.length > 0) {
                        var vals = allowDrawWeekDay.split(",");
                        for(i = 0; i < vals.length; i++) {
                            $("input[name='allowDrawWeekDay']")[vals[i]-1].checked=true;
                        }
                    }
                    $('#drawDayStartTime').val(res.data.drawDayStartTime);
                    $('#drawDayEndTime').val(res.data.drawDayEndTime);
                    $('#dayDrawTimes').val(res.data.dayDrawTimes);
                    $('#drawMaxDayAmount').val(res.data.drawMaxDayAmount/100);
                    $('#maxDrawAmount').val(res.data.maxDrawAmount/100);
                    $('#minDrawAmount').val(res.data.minDrawAmount/100);

                    if(res.data.feeType == 1) {
                        $("input[name='feeType'][value='1']").attr("checked",true);
                        $("#feeRateId").show();
                        $("#feeLevelId").hide();
                        $("#drawFeeLimitId").show();
                    }else if(res.data.feeType == 2) {
                        $("input[name='feeType'][value='2']").attr("checked",true);
                        $("#feeRateId").hide();
                        $("#feeLevelId").show();
                        $("#drawFeeLimitId").hide();
                    }else if(res.data.feeType == 3) {
                        $("input[name='feeType'][value='3']").attr("checked",true);
                        $("#feeRateId").show();
                        $("#feeLevelId").show();
                        $("#drawFeeLimitId").show();
                    }
                    $('#feeRate').val(res.data.feeRate);
                    $('#feeLevel').val(res.data.feeLevel/100);
                    $('#drawFeeLimit').val(res.data.drawFeeLimit/100);
                    $("input[name='settType'][value='"+res.data.settType+"']").attr("checked",true);
                    $("input[name='settMode'][value='"+res.data.settMode+"']").attr("checked",true);

                    $('#siteTitle').val(res.data.siteTitle);
                    $('#copyRight').val(res.data.copyRight);
                    $('#serviceTel').val(res.data.serviceTel);
                    $('#serviceQQ').val(res.data.serviceQQ);

                    setImgValFunc("siteLogo", res.data.siteLogo);  //载入图片
                    setImgValFunc("mchHomeBanner", res.data.mchHomeBanner);  //载入图片
                    setImgValFunc("siteIcon", res.data.siteIcon);  //载入图片

                    $('#statisticalCode').val(res.data.statisticalCode);
                    $('#mainAdvert').val(res.data.mainAdvert);
                    $('#mainAdvertEn').val(res.data.mainAdvertEn);
                    $('#subAdvert').val(res.data.subAdvert);

                    $('input[name="agentpayOutAccount"][value="'+res.data.agentpayOutAccount+'"]').attr('checked', true);
                    $('input[name="agentpayAuditType"][value="'+res.data.agentpayAuditType+'"]').attr('checked', true);

                    //商户通道使用规则
                    $('input[name="agentpayMchConfigFlag"][value="'+res.data.agentpayMchConfigFlag+'"]').attr('checked', true);
                    $('input[name="agentpayMchConfig2QueryOrderTime"]').val(res.data.agentpayMchConfig2QueryOrderTime);
                    if(res.data.agentpayMchConfigFlag == 2){
                        $("#agentpayMchConfig2QueryOrderTimeDIV").removeClass('layui-hide');
                    }
                    $('#payApiDoc').val(res.data.payApiDoc);
                    $('#agentpayApiDoc').val(res.data.agentpayApiDoc);


                    //系统参数配置
                    $('#applicationConfigDiv input[name="mgrSiteUrl"]').val(res.data.mgrSiteUrl);
                    $('#applicationConfigDiv input[name="mchSiteUrl"]').val(res.data.mchSiteUrl);
                    $('#applicationConfigDiv input[name="agentSiteUrl"]').val(res.data.agentSiteUrl);
                    $('#applicationConfigDiv input[name="paySiteUrl"]').val(res.data.paySiteUrl);
                    $('#applicationConfigDiv input[name="taskReissuePayIp"]').val(res.data.taskReissuePayIp);
                    $('#applicationConfigDiv input[name="taskReissueTransIp"]').val(res.data.taskReissueTransIp);
                    if(res.data.taskReissuePaySwitch == 'true'){
                        $('#applicationConfigDiv input[name="taskReissuePaySwitch"]').prop('checked', true);
                        $('#applicationConfigDiv .taskReissuePayIpDiv').removeClass('layui-hide');
                    }
                    if(res.data.taskReissueTransSwitch == 'true'){
                        $('#applicationConfigDiv input[name="taskReissueTransSwitch"]').prop('checked', true);
                        $('#applicationConfigDiv .taskReissueTransIpDiv').removeClass('layui-hide');
                    }

                    $('#wxOauth2CodeUrl').val(res.data.wxOauth2CodeUrl);
                    $("input[name='cleanFlag'][value='"+res.data.cleanFlag+"']").attr("checked",true);
                    $("input[name='supModeIsOpen'][value='"+res.data.supModeIsOpen+"']").attr("checked",true);


                    //【上传文件设置】
                    $("input[name='uploadFileSaveType'][value='"+res.data.uploadFileSaveType+"']").prop('checked', true);
                    if(res.data.uploadFileSaveType == 2){ //阿里云oss
                        $(".aliyunOssDiv").removeClass("layui-hide");
                    }
                    $("#ossEndpoint").val(res.data.ossEndpoint);
                    $("#ossBucketName").val(res.data.ossBucketName);
                    $("#ossAccessKeyId").val(res.data.ossAccessKeyId);
                    $("#ossAccessKeySecret").val(res.data.ossAccessKeySecret);

                    //短信配置项
                    let smsConfig = JSON.parse(res.data.smsConfig);
                    $("#smsAccessKeyId").val(smsConfig.accessKeyId);
                    $("#smsAccessKeySecret").val(smsConfig.accessKeySecret);
                    $("#smsSignName").val(smsConfig.signName);

                    // 登录安全配置
                    $("#btSignConfig").val(res.data.btSignConfig);
                    $("#btUrlConfig").val(res.data.btUrlConfig);
                    $("#loginCountConfig").val(res.data.loginCountConfig);
                    $("input[name='loginToBlackType'][value='"+res.data.loginToBlackType+"']").prop('checked', true);
                    if(res.data.loginToBlackType == 0) {
                        $(".loginToBlackType").addClass("layui-hide");
                    }else {
                        $(".loginToBlackType").removeClass("layui-hide");
                    }
                    // 代付打款配置
                    $("input[name='agentpayCheckRepeatFlag'][value='"+res.data.agentpayCheckRepeatFlag+"']").prop('checked', true);
                    if(res.data.agentpayCheckRepeatFlag == 0){ // 不验证

                        $(".agentpayCheckRepeatTimeDiv").addClass("layui-hide");
                    }else{                                     // 验证
                        $(".agentpayCheckRepeatTimeDiv").removeClass("layui-hide");
                    }
                    $("#agentpayCheckRepeatTime").val(res.data.agentpayCheckRepeatTime);
                    // 代付抢单模式
                    $("input[name='agentpaySnatchFlag'][value='"+res.data.agentpaySnatchFlag+"']").prop('checked', true);
                    //短信模板
                    table.render({
                        elem: '#XxPay_SmsConfig_Poll_dataAll',
                        id: 'tableReload',
                        cols: [
                            [{
                                field: 'bizType',
                                title: '业务代码',
                                style: "background-color: gainsboro"
                            }, {
                                field: 'bizName',
                                title: '业务名称',
                                style: "background-color: gainsboro"
                            }, {
                                field: 'templateParam',
                                title: '模板内容',
                                style: "background-color: gainsboro"
                            }, {
                                field: 'templateCode',
                                edit: 'text',
                                title: '模板code',
                                style: "padding: 2px;border: 1px solid;",
                            }]
                        ],
                        page: false,
                        limit: 100,
                        skin: 'line',
                        data: smsConfig.smsTemplates
                    });

                    if(res.data.mgrPayOrderAllTipFlag == '1'){
                        $("input[name='mgrPayOrderAllTipFlag']").prop('checked', true);
                        $("input[name='mgrPayOrderAllTipFlag']").parent().find('.sysTipsSoundSpan').removeClass('layui-hide');
                    }
                    if(res.data.mgrPayOrderSoundFlag == '1'){
                        $("input[name='mgrPayOrderSoundFlag']").prop('checked', true);
                    }
                    if(res.data.mgrAgentpayOrderAllTipFlag == '1'){
                        $("input[name='mgrAgentpayOrderAllTipFlag']").prop('checked', true);
                        $("input[name='mgrAgentpayOrderAllTipFlag']").parent().find('.sysTipsSoundSpan').removeClass('layui-hide');
                    }
                    if(res.data.mgrAgentpayOrderSoundFlag == '1'){
                        $("input[name='mgrAgentpayOrderSoundFlag']").prop('checked', true);
                    }
                    if(res.data.mgrSettOrderAllTipFlag == '1'){
                        $("input[name='mgrSettOrderAllTipFlag']").prop('checked', true);
                        $("input[name='mgrSettOrderAllTipFlag']").parent().find('.sysTipsSoundSpan').removeClass('layui-hide');
                    }
                    if(res.data.mgrSettOrderSoundFlag == '1'){
                        $("input[name='mgrSettOrderSoundFlag']").prop('checked', true);
                    }

                    //代付审核允许的打款方式
                    var agentpayChoosePayTypeArray = JSON.parse(res.data.agentpayChoosePayType);
                    $(agentpayChoosePayTypeArray).each(function(){
                        $("input[name='agentpayChoosePayType'][value='"+this+"']").prop('checked', true);
                    });

                    form.render();
                }
            }
        })

        form.on('submit(system_config)', function(data) {
            //提交表单
            admin.req({
                type: "POST",
                url: layui.setter.baseUrl + '/sys/config/update',
                data: data.field,
                success: function(res){
                    if(res.code == 0) {
                        layer.alert(res.msg, {title: "保存成功"}, function (index) {
                            layer.close(index);
                        });
                    }
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

        form.on('submit(updateSmsConfig)', function(data) {

            let dataArray = JSON.parse(JSON.stringify(table.cache['tableReload']));
            for(let i = 0; i < dataArray.length; i++){
                delete dataArray[i].LAY_TABLE_INDEX; //删除LAY_TABLE_INDEX字段，避免提示sql注入风险
            }

            data.field.smsTemplates = dataArray;

            let reqData = {
                type: data.field.type,
                smsConfig: JSON.stringify(data.field)
            };

            //提交表单
            admin.req({
                type: "POST",
                url: layui.setter.baseUrl + '/sys/config/update',
                data: reqData,
                success: function(res){
                    if(res.code == 0) {
                        layer.alert(res.msg, {title: "保存成功"}, function (index) {
                            layer.close(index);
                        });
                    }
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });


        form.on('submit(updateUploadConfigFilter)', function(data) {

            if(data.field.uploadFileSaveType == 2){ //阿里云oss存储

                if(!data.field.ossEndpoint){ return layer.msg("请输入EndPoint地域节点!", {icon: 2}); }
                if(!data.field.ossBucketName){ return layer.msg("请输入bucketName!", {icon: 2}); }
                if(!data.field.ossAccessKeyId){ return layer.msg("请输入accessKeyId!", {icon: 2}); }
                if(!data.field.ossAccessKeySecret){ return layer.msg("请输入accessKeySecret!", {icon: 2}); }
                if(data.field.ossEndpoint.startsWith("http://") || data.field.ossEndpoint.startsWith("https://")){ return layer.msg("EndPoint输入有误！", {icon: 2}); }
            }

            //提交表单
            admin.req({
                type: "POST",
                url: layui.setter.baseUrl + '/sys/config/update',
                data: data.field,
                success: function(res){
                    if(res.code == 0) {
                        layer.alert(res.msg, {title: "保存成功"}, function (index) {
                            layer.close(index);
                        });
                    }
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

        form.on('submit(safe_config)', function(data) {
            //提交表单
            admin.req({
                type: "POST",
                url: layui.setter.baseUrl + '/sys/config/update',
                data: data.field,
                success: function(res){
                    if(res.code == 0) {
                        layer.alert(res.msg, {title: "保存成功"}, function(index){
                            layer.close(index);
                        });
                    }
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

        form.on('submit(sett_config)', function(data) {
            // 将星期几形成1,2,3格式
            var allowDrawWeekDayCheckbox = $("input[name='allowDrawWeekDay']");
            var vals = "";
            for(i = 0; i < allowDrawWeekDayCheckbox.length; i++){
                if(allowDrawWeekDayCheckbox[i].checked){
                    var val = allowDrawWeekDayCheckbox[i].value;
                    if(vals.length>0){
                        vals += "," + val;
                    }else{
                        vals += val;
                    }
                }
            }
            data.field.allowDrawWeekDay = vals;

            //提交表单
            admin.req({
                type: "POST",
                url: layui.setter.baseUrl + '/sys/config/update',
                data: data.field,
                success: function(res){
                    if(res.code == 0) {
                        layer.alert(res.msg, {title: "保存成功"}, function(index){
                            layer.close(index);
                        });
                    }
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。

        });

        form.on('submit(agentpay_config)', function(data) {
            if (data.field.agentpayCheckRepeatFlag == 1) {
                if (!data.field.agentpayCheckRepeatTime || data.field.agentpayCheckRepeatTime*1 <= 0) {
                    layer.alert("请输入正确的金额验证频率！");
                    return false;
                }
            }

            let agentpayChoosePayTypeArray = $("input[name='agentpayChoosePayType']:checked");
            if(agentpayChoosePayTypeArray.length == 0){
                layer.alert("至少选择一种打款方式！");
                return false;
            }

            let agentpayChoosePayTypeArrayVal = [];
            $(agentpayChoosePayTypeArray).each(function(){
                agentpayChoosePayTypeArrayVal.push($(this).val());
            });

            data.field.agentpayChoosePayType = JSON.stringify(agentpayChoosePayTypeArrayVal);

            //提交表单
            admin.req({
                type: "POST",
                url: layui.setter.baseUrl + '/sys/config/update',
                data: data.field,
                success: function(res){
                    if(res.code == 0) {
                        layer.alert(res.msg, {title: "保存成功"}, function(index){
                            layer.close(index);
                        });
                    }
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

        form.on('submit(doc_config)', function(data) {
            //提交表单
            admin.req({
                type: "POST",
                url: layui.setter.baseUrl + '/sys/config/update',
                data: data.field,
                success: function(res){
                    if(res.code == 0) {
                        layer.alert(res.msg, {title: "保存成功"}, function(index){
                            layer.close(index);
                        });
                    }
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

        form.on('submit(application_config)', function(data) {

            //重新赋值
            data.field.taskReissuePaySwitch = data.field.taskReissuePaySwitch == 'on' ? 'true' : 'false';
            data.field.taskReissueTransSwitch = data.field.taskReissueTransSwitch == 'on' ? 'true' : 'false';
            //提交表单
            admin.req({
                type: "POST",
                url: layui.setter.baseUrl + '/sys/config/update',
                data: data.field,
                success: function (res) {
                    if (res.code == 0) {
                        layer.alert(res.msg, {title: "保存成功"}, function (index) {
                            layer.close(index);
                        });
                    }
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
        form.on('submit(login_safe_config)', function(data) {
            if (data.field.loginToBlackType == '1') {
                if (!data.field.btSignConfig || !data.field.btUrlConfig) {
                    layer.alert("宝塔配置不能为空！");
                    return false;
                }
            }
            // 判断次数为空的情况
            if (!data.field.loginCountConfig) {
                data.field.loginCountConfig = 0;
            }
            // 判断次数长度 [限制 < 100]
            if (data.field.loginCountConfig.length >= 3 || data.field.loginCountConfig < 0) {
                layer.alert("请设置正确的次数！");
                return false;
            }

            //提交表单
            admin.req({
                type: "POST",
                url: layui.setter.baseUrl + '/sys/config/update',
                data: data.field,
                success: function (res) {
                    if (res.code == 0) {
                        layer.alert(res.msg, {title: "保存成功"}, function (index) {
                            layer.close(index);
                        });
                    }
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

        form.on('radio(feeTypeFilter)', function(data){
            if(data.value == 1) {
                $("#feeRateId").show();
                $("#feeLevelId").hide();
                $("#drawFeeLimitId").show();
            }else if(data.value == 2) {
                $("#feeRateId").hide();
                $("#feeLevelId").show();
                $("#drawFeeLimitId").hide();
            }else if(data.value == 3) {
                $("#feeRateId").show();
                $("#feeLevelId").show();
                $("#drawFeeLimitId").show();
            }
        });

        form.on('switch(taskReissuePaySwitchFilter)', function(data){
            if(data.elem.checked) {
                $('#applicationConfigDiv .taskReissuePayIpDiv').removeClass('layui-hide');
            }else {
                $('#applicationConfigDiv .taskReissuePayIpDiv').addClass('layui-hide');
            }
        });

        form.on('switch(taskReissueTransSwitchFilter)', function(data){
            if(data.elem.checked) {
                $('#applicationConfigDiv .taskReissueTransIpDiv').removeClass('layui-hide');
            }else {
                $('#applicationConfigDiv .taskReissueTransIpDiv').addClass('layui-hide');
            }
        });

        form.on('checkbox(chooseAll)', function(data){
            var checkElem = $("input[name='cleanTableCheck']");
            checkElem.each(function (index, item) {
                item.checked = data.elem.checked;
            });
            form.render('checkbox');
        });

        form.on('select(dateSelectFilter)', function(data){
            var customTime = $("#dataSelect").val();
            if (customTime == "2") {
                $("#customTime").show();
            } else{
                $("#customTime").hide();
            }
            form.render();
        });

        form.on('submit(clean_config)', function(data) {
            var customTime = $("#dataSelect").val();
            var cleanTime;
            if (customTime == "2") {
                cleanTime = $("#cleanTime").val();
                if (cleanTime == "" || cleanTime == null){
                    layer.alert("请选择时间范围！");
                    return false;
                }
            } else if (customTime == "1") {
                cleanTime = "";
            }

            // 将所选数据表转成1,2,3格式
            var cleanTableCheck = $("input[name='cleanTableCheck']");
            var vals = "";
            for(i = 0; i < cleanTableCheck.length; i++){
                if(cleanTableCheck[i].checked){
                    var val = cleanTableCheck[i].value;
                    if(vals.length>0){
                        vals += "," + val;
                    }else{
                        vals += val;
                    }
                }
            }
            if (vals.length <= 0) {
                layer.alert("请选择要清理的表！");
                return false;
            }

            //提交表单
            layer.prompt({title: '请输入平台超级密码', formType: 1}, function(pass, proId){
                layer.close(proId);
                var load = layer.msg('数据清除中...', {
                    icon: 16
                    ,shade: 0.01
                    ,time: 9999999999
                });
                admin.req({
                    type: "POST",
                    url: layui.setter.baseUrl + '/sys/config/clean',
                    timeout: 1000*60,
                    data: {
                        pass: pass,
                        customTime: customTime,
                        cleanTableCheck: vals,
                        cleanTime: cleanTime
                    },
                    error: function(err){
                        layer.close(load);
                        layer.alert(err);
                    },
                    success: function(res){
                        layer.close(load);
                        if(res.code == 0) {
                            layer.alert("共删除"+res.data+"条数据", {title: "删除成功"}, function(index){
                                layer.close(index);
                                admin.events.refresh();
                            });
                        }
                    }
                });

                return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            });
        });

        form.on('submit(update_sys_tips_config)', function(data) {

            data.field.mgrPayOrderAllTipFlag = data.field.mgrPayOrderAllTipFlag ? "1" : "0";
            data.field.mgrPayOrderSoundFlag = data.field.mgrPayOrderSoundFlag ? "1" : "0";
            data.field.mgrAgentpayOrderAllTipFlag = data.field.mgrAgentpayOrderAllTipFlag ? "1" : "0";
            data.field.mgrAgentpayOrderSoundFlag = data.field.mgrAgentpayOrderSoundFlag ? "1" : "0";
            data.field.mgrSettOrderAllTipFlag = data.field.mgrSettOrderAllTipFlag ? "1" : "0";
            data.field.mgrSettOrderSoundFlag = data.field.mgrSettOrderSoundFlag ? "1" : "0";


            //提交表单
            admin.req({
                type: "POST",
                url: layui.setter.baseUrl + '/sys/config/update',
                data: data.field,
                success: function (res) {
                    if (res.code == 0) {
                        layer.alert("保存成功, 请刷新浏览器页面后生效！", {title: "提示"}, function (index) {
                            layer.close(index);
                        });
                    }
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。

        });

        form.on('radio(agentpayMchConfigFlagFilter)', function(data){
            if (data.value == "2") { //轮询

                $("#agentpayMchConfig2QueryOrderTimeDIV").removeClass('layui-hide');

            } else { //关闭

                $("#agentpayMchConfig2QueryOrderTimeDIV").addClass('layui-hide');
            }
        });

        form.on('radio(loginToBlackTypeFilter)', function(data){
            if(data.value == 0) {
               $(".loginToBlackType").addClass("layui-hide");
            }else {
                $(".loginToBlackType").removeClass("layui-hide");
            }
        });

        laydate.render({
            elem: '#drawDayStartTime'
            ,type: 'time'
            ,format: 'HH:mm:ss'
        });

        laydate.render({
            elem: '#drawDayEndTime'
            ,type: 'time'
            ,format: 'HH:mm:ss'
        });

        laydate.render({
            elem: '#cleanTime'
            ,type: 'datetime'
            ,format: 'yyyy-MM-dd HH:mm:ss'
        });


        form.on("radio(uploadFileSaveTypeFilter)", function(data){

            if(data.value == 1){ //本地存储

                $(".aliyunOssDiv").addClass("layui-hide");
            }else{ //阿里云oss
                $(".aliyunOssDiv").removeClass("layui-hide");
            }
        });

        form.on("radio(agentpayCheckRepeatFlagFilter)", function(data){

            if(data.value == 0){ // 不验证

                $(".agentpayCheckRepeatTimeDiv").addClass("layui-hide");
            }else{ // 验证
                $(".agentpayCheckRepeatTimeDiv").removeClass("layui-hide");
            }
        });


        form.on('switch(sysTipSwitch)', function(data){

            if(data.elem.checked){
                $(data.elem).parent().find('.sysTipsSoundSpan').removeClass('layui-hide');
            }else{
                $(data.elem).parent().find('.sysTipsSoundSpan').addClass('layui-hide');
            }
        });

        element.render();
        form.render();
    })
</script>
